#!/bin/bash
exec_name=EttaM1
dist_home=$(pwd)/..
autostart_dir=/etc/profile.d
cur_user=$(who | awk '{print $1}')
exec_home=/home/${cur_user}/${exec_name}

make_autostart_shell() {
echo "#!/bin/bash"
#echo "cd ${dist_home}/"
#echo "echo 123 | sudo -S ./${exec_name}"
echo "cd ${exec_home}/"
echo "./${exec_name}"
}

make_autostart_shell >${exec_name}-autostart.sh
echo 123 | sudo -S mv -f ${exec_name}-autostart.sh ${autostart_dir}/

for i in "$@"; do
  if [ "${i}" == "reboot" ]; then
    option="reboot"
    break
  fi
done

case $option in
  "reboot")
    echo 123 | sudo -S systemctl restart gdm
    #reboot
    ;;

  *)
    ;;
esac